<template>
	<div>
		<div v-if="list.length > 0">
			<div v-for="(item, index) in list">
				<Lessor
					ref="Lessor"
					v-if="item.changeType == '1'"
					v-model="list[index]"
					state="readonly"
					:deptList="deptList"></Lessor>
				<Leasee
					ref="Leasee"
					v-if="item.changeType == '2'"
					v-model="list[index]"
					state="readonly"></Leasee>
				<Time
					ref="Time"
					v-if="item.changeType == '3'"
					v-model="list[index]"
					state="readonly"></Time>
			</div>
		</div>
		<div v-else>
			<el-empty description="暂无变更记录！"></el-empty>
		</div>
	</div>
</template>

<script>
	import * as app from '@/api/app.js';
	import * as apis from '@/api/order/mainOrder/contractChange/api.js';
	import Leasee from '../chunk/adjust/leasee/index.vue';
	import Lessor from '../chunk/adjust/lessor/index.vue';
	import Time from '../chunk/adjust/time/index.vue';
	export default {
		name: '',
		components: { Leasee, Lessor, Time },
		props: {},
		data() {
			return {
				deptList: {
					company: [],
				},
				list: [],
			};
		},
		computed: {},
		created() {
			this.getDetails();
			this.getDeptList(2);
		},
		mounted() {},
		methods: {
			getDetails() {
				let params = {
					orderId: this.$route.query.orderId,
					flowStatus: 3,
				};
				apis.OrderChangeList(params).then(res => {
					console.log(res);
					this.list = res.rows ?? [];
				});
			},
			getDeptList(deptType) {
				let params = {
					deptType,
				};
				app.DeptListNoPermission(params).then(res => {
					if (res.code == 200) {
						res?.data?.map(item => {
							item.deptId = item.deptId?.toString();
						});
						switch (deptType) {
							case 1:
								this.deptList.department = res?.data ?? [];
								break;
							case 2:
								this.deptList.company = res?.data ?? [];
								break;
						}
					}
				});
			},
		},
	};
</script>

<style lang="scss" scoped></style>
